import { Define, EntityObjectFactory } from 'tiny-entity2';
const EntityObjectType = EntityObjectFactory.GetEntityObjectType(process.env.dataBaseType || 'mysql');

@Define.Table({ TableName: "orderpayment" })
export class OrderPayment extends EntityObjectType<OrderPayment>{
    @Define.PrimaryKey()
    id: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        // IsIndex: true,
        NotAllowNULL: true
    })
    orderId: string

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        IsIndex: true,
        NotAllowNULL: true
    })
    paymentId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    paymentName: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    paymentChannelId: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT,
        IsIndex: true,
        NotAllowNULL: true
    })
    payTime: number;

    @Define.Column({
        DataType: Define.DataType.Decimal,
        DefaultValue: 0,
        DataLength: 10,
        DecimalPoint: 3
    })
    amount: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    operatorId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true
    })
    operatorName: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        // IsIndex: true,
    })
    payType: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    refPaymentId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    couponId: string;

    @Define.Column({
        DataType: Define.DataType.VARCHAR
    })
    couponName: string;

    @Define.Column({
        DataType: Define.DataType.Decimal
    })
    couponDenomination: number;

    @Define.Column({
        DataType: Define.DataType.Decimal
    })
    couponAmount: number;

    @Define.Column({
        DataType: Define.DataType.Decimal
    })
    couponCount: number;

    @Define.Column({
        DataType: Define.DataType.VARCHAR,
        NotAllowNULL: true,
        IsIndex: true
    })
    storeId: string;

    @Define.Column({
        DataType: Define.DataType.BIGINT
    })
    version: number;
}

export const OrderPaymentType = {
    pay: 'pay',     // 正常支付
    revoke: 'revoke',   //支付回退
    refund: 'refund',    //原支付标记已退
    unknown:  'unknown' //支付状态未知，用于支付宝，微信的查询
}